package com.sondon.mayi.util;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.sondon.mayi.activity.CartActivity_;
import com.sondon.mayi.fruit.R;

/**
 * @Project : Fruit
 * @Package : com.sondon.mayi.util
 * @Class : MyAlertDialog
 * @Author : 蔡文锋
 * @DateTime：2015年7月4日 下午9:15:33
 * @Blog：http://blog.csdn.net/caiwenfeng_for_23
 * @Description : { 自定义弹出提示框}
 *
 */
public class MyAlertDialog {
	public static Dialog mydialog=null;
	public static TextView dialog_left;
	public static TextView dialog_right;
	
	@SuppressLint("InflateParams")
	public static void show(final Context context,String title,String content,String left_txt,String right_txt){
		
		LayoutInflater layoutInflater = LayoutInflater.from(context);
		LinearLayout  myview = (LinearLayout)layoutInflater.inflate(R.layout.my_alertdialog, null );
		
		//设置对话框显示布局
		mydialog = new AlertDialog.Builder(context).create();
		mydialog.show();
		mydialog.getWindow().setContentView(myview);
       
		//获取控件
       TextView dialog_title=(TextView) myview.findViewById(R.id.dialog_title);
       TextView dialog_content=(TextView) myview.findViewById(R.id.dialog_content);
       dialog_left=(TextView) myview.findViewById(R.id.dialog_left);
       dialog_right=(TextView) myview.findViewById(R.id.dialog_right);
       
       //设置每个textview的内容
       dialog_title.setText(title);
       dialog_content.setText(content);
       dialog_left.setText(left_txt);
       dialog_right.setText(right_txt);
	}
	
	//设置监听事件
	public static void setLeftRightListener(OnClickListener leftListener,OnClickListener rightListener){
		 //左边按钮监听事件
	       dialog_left.setOnClickListener(leftListener);
	      //右边按钮监听事件
	       dialog_right.setOnClickListener(rightListener);
	}

	public static Dialog getMydialog() {
		return mydialog;
	}
}
